<?php

require PATH_MODELS . 'MenuModel.class.php';

/**
 * 全局设置类
 */
class GlobalPage extends BasePage {

    private $M;
    private $way = '';
    // 新闻表
    static private $news = 'tb_news';
    // 广告菜单分类表
    static private $advert_menu = 'tb_advert';
    // 广告表
    static private $advert_list = 'tb_advert_list';
    // seo信息表
    static private $seo = 'tb_seo';
    // smtp邮件表信息
    static private $smtp = 'tb_smtp';

    /**
     * 构造方法
     */
    function __construct() {
        parent::checkUserLogin();
        $this->M = new MenuModel();
        $this->way = isset($_GET['way']) ? trim($_GET['way']) : '';
        parent::getMenuList($this->M);
    }

    /**
     * 新闻资讯管理
     */
    function newsInfo() {
        $catagory = array(
            0 => '首页', 1 => '国内', 2 => '国际', 3 => '社会', 4 => '法制', 5 => '军事', 6 => '财经', 7 => '科技', 8 => '汽车'
        );
        if ($this->way == 'A') {
            if (!$_POST) {
                include PATH_VIEWS . 'global/news/add.php';
            } else {
                $data = array(
                    'Fcategory' => isset($_POST['Fcategory']) ? intval($_POST['Fcategory']) : 0,
                    'Ftitle' => isset($_POST['Ftitle']) ? trim($_POST['Ftitle']) : '',
                    'Fstit' => isset($_POST['Fstit']) ? trim($_POST['Fstit']) : '',
                    'Fsource' => isset($_POST['Fsource']) ? trim($_POST['Fsource']) : '',
                    'FaddTime' => (!isset($_POST['FaddTime'])) ? strtotime($_POST['FaddTime']) : time(),
                    'Fname' => isset($_POST['Fname']) ? trim($_POST['Fname']) : '',
                    'Fabstract' => isset($_POST['Fabstract']) ? trim($_POST['Fabstract']) : '',
                    'Fkeyword' => isset($_POST['Fkeyword']) ? trim($_POST['Fkeyword']) : '',
                    'Fsort' => isset($_POST['Fsort']) ? trim($_POST['Fsort']) : '',
                    'Fstatus' => isset($_POST['Fstatus']) ? intval($_POST['Fstatus']) : '',
                    'Fcontent' => isset($_POST['Fcontent']) ? trim($_POST['Fcontent']) : ''
                );
//                判断上传的图片是否存在并且不能为空
                if (isset($_FILES['Fimg']['name']) && !empty($_FILES['Fimg']['name'])) {
//                基本使用方法:
                    $file = new ExtendsYspUploadFile();
                    $file->max_size = 2 * 1024 * 1024; //       //限制文件大小 字节
                    $file->allow_type = "gif/jpg/bmp/png"; //允许上传的文件类型
                    $file->input_name = "Fimg";           //表单中的文本域名称
                    $file->save_path = PATH_UPLOAD . '/news';      //保存路径
                    $file->rand_name = false;                   //随机文件名 (默认)
                    $file->reset_name = time() . '_' . BaseYspCookie::getCookie($_COOKIE['admin']['id']) . '_' . rand(0, 100);   //重命名
                    if ($file->save()) {
//                    echo "ok";               //保存文件，成功返回 true
                        $data['Fimg'] = str_replace(PATH_UPLOAD, '', $file->file_upload_path);
                    }
                }
                $rs = $this->M->addMenu(self::$news, $data);
                if ($rs > 0) {
                    $href = str_replace('way=A', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }

        if ($this->way == 'S') {
            //分页参数设置
            //当前页码
            $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
            //每页条数
            $pagesize = 10;
            $page = ($page < 1) ? 1 : $page;
            //起始条数
            $start = ($page - 1) * $pagesize;
            //查询关键字
            $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : '';
            $where = $keywords ? "WHERE Fname LIKE '%$keywords%'" : '';

            //取总记录数
            $total = $this->M->getTotal(self::$news, $where);
            $info_list = $this->M->getList(self::$news, 'Fid,Fcategory,Ftitle,Fsource,FaddTime,Fname,Fkeyword,Fsort,Fstatus', $where, 'ORDER BY Fsort,FaddTime', "LIMIT $start,$pagesize");
            if ($total > 0) {
                $Pager = new ExtendsYspPager();
                $pagerlink = $Pager->getPager($total, $page, $pagesize);
            } else {
                $pagerlink = '对不起，没有相关信息';
            }
            include PATH_VIEWS . 'global/news/list.php';
        }
        if ($this->way == 'E') {
            if (!$_POST) {
                $edit = $this->M->getView(self::$news, 'Fid');
                include PATH_VIEWS . 'global/news/edit.php';
            } else {
                $data = array(
                    'Fcategory' => isset($_POST['Fcategory']) ? intval($_POST['Fcategory']) : 0,
                    'Ftitle' => isset($_POST['Ftitle']) ? trim($_POST['Ftitle']) : '',
                    'Fstit' => isset($_POST['Fstit']) ? trim($_POST['Fstit']) : '',
                    'Fsource' => isset($_POST['Fsource']) ? trim($_POST['Fsource']) : '',
                    'FaddTime' => (!isset($_POST['FaddTime'])) ? strtotime($_POST['FaddTime']) : time(),
                    'Fname' => isset($_POST['Fname']) ? trim($_POST['Fname']) : '',
                    'Fabstract' => isset($_POST['Fabstract']) ? trim($_POST['Fabstract']) : '',
                    'Fkeyword' => isset($_POST['Fkeyword']) ? trim($_POST['Fkeyword']) : '',
                    'Fsort' => isset($_POST['Fsort']) ? trim($_POST['Fsort']) : '',
                    'Fstatus' => isset($_POST['Fstatus']) ? intval($_POST['Fstatus']) : '',
                    'Fcontent' => isset($_POST['Fcontent']) ? trim($_POST['Fcontent']) : ''
                );
//                判断上传的图片是否存在并且不能为空
                if (isset($_FILES['Fimg']['name']) && !empty($_FILES['Fimg']['name'])) {
//                基本使用方法:
                    $file = new ExtendsYspUploadFile();
                    $file->max_size = 2 * 1024 * 1024; //       //限制文件大小 字节
                    $file->allow_type = "gif/jpg/bmp/png"; //允许上传的文件类型
                    $file->input_name = "Fimg";           //表单中的文本域名称
                    $file->save_path = PATH_UPLOAD . 'news';      //保存路径
                    $file->rand_name = false;                   //随机文件名 (默认)
                    $file->reset_name = time() . '_' . BaseYspCookie::getCookie($_COOKIE['admin']['id']) . '_' . rand(0, 100);   //重命名
                    if ($file->save()) {
//                    echo "ok";               //保存文件，成功返回 true
                        $data['Fimg'] = str_replace(PATH_UPLOAD, '', $file->file_upload_path);
                    }
                }
                $rs = $this->M->Edit(self::$news, $data, 'Fid');
                if ($rs > 0) {
                    $href = str_replace('way=E', 'way=S', URL);
                    parent::getMsg('right', '修改成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '修改失败', URL);
                }
            }
        }
        if ($this->way == 'D') {
            $rs = $this->M->Del(self::$news, 'Fid');
            if ($rs !== false) {
                $href = str_replace('&way=D', '&way=S', URL);
                parent::getMsg('right', '操作成功', $href);
                exit;
            } else {
                parent::getMsg('wrong', '对不起，操作失败', URL);
                exit;
            }
        }
    }

    /**
     * 广告分类管理
     */
    function adCategory() {
        if ($this->way == 'A') {
            if (!$_POST) {
                include PATH_VIEWS . 'global/advert_classify/add.php';
            } else {
                $data = array(
                    'Fname' => isset($_POST['name']) ? trim($_POST['name']) : '',
                    'Fsort' => isset($_POST['sort']) ? trim($_POST['sort']) : ''
                );
                $rs = $this->M->addMenu(self::$advert_menu, $data);
                if ($rs > 0) {

                    $href = str_replace('way=A', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }

        if ($this->way == 'S') {
            //分页参数设置
            //当前页码
            $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
            //每页条数
            $pagesize = 10;
            $page = ($page < 1) ? 1 : $page;
            //起始条数
            $start = ($page - 1) * $pagesize;
            //查询关键字
            $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : '';
            $where = $keywords ? "WHERE Fname LIKE '%$keywords%'" : '';

            //取总记录数
            $total = $this->M->getTotal(self::$advert_menu, $where);
            $info_list = $this->M->getList(self::$advert_menu, 'Fid,Fname,Fsort', $where, 'ORDER BY Fsort', "LIMIT $start,$pagesize");
            if ($total > 0) {
                $Pager = new ExtendsYspPager();
                $pagerlink = $Pager->getPager($total, $page, $pagesize);
            } else {
                $pagerlink = '对不起，没有相关信息';
            }
            include PATH_VIEWS . 'global/advert_classify/list.php';
        }

        if ($this->way == 'E') {
            if (!$_POST) {
                $edit = $this->M->getView(self::$advert_menu, 'Fid');
                include PATH_VIEWS . 'global/advert_classify/edit.php';
            } else {
                $data = array(
                    'Fname' => isset($_POST['name']) ? trim($_POST['name']) : '',
                    'Fsort' => isset($_POST['sort']) ? trim($_POST['sort']) : ''
                );
                $rs = $this->M->Edit(self::$advert_menu, $data, 'Fid');
                if ($rs > 0) {
                    $href = str_replace('way=E', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }

        if ($this->way == 'D') {
            $rs = $this->M->Del(self::$advert_menu, 'Fid');
            if ($rs !== false) {
                $href = str_replace('&way=D', '&way=S', URL);
                parent::getMsg('right', '操作成功', $href);
                exit;
            } else {
                parent::getMsg('wrong', '对不起，操作失败', URL);
                exit;
            }
        }
    }

    /**
     * 广告位管理
     */
    function advertManage() {
        // 广告位添加
        if ($this->way == "A") {
            if (!$_POST) {
                $menu_list = $this->M->getList(self::$advert_menu, 'Fid,Fname');
                include PATH_VIEWS . 'global/advert_manage/add.php';
            } else {
                if ($_POST['FcateId'] == 0 || $_POST['FcateId'] == '') {
                    parent::getMsg('wrong', '请选择分类', URL);
                }
                $data = array(
                    "FcateId" => isset($_POST['FcateId']) ? intval($_POST['FcateId']) : 0,
                    "Fname" => isset($_POST['Fname']) ? trim($_POST['Fname']) : "",
                    "Fnum" => isset($_POST['Fnum']) ? trim($_POST['Fnum']) : "",
                    "Flink" => isset($_POST['Flink']) ? trim($_POST['Flink']) : "",
                    "FbgColor" => isset($_POST['FbgColor']) ? trim($_POST['FbgColor']) : "",
                    "Fwidth" => isset($_POST['Fwidth']) ? intval($_POST['Fwidth']) : 0,
                    "Fheight" => isset($_POST['Fheight']) ? intval($_POST['Fheight']) : 0,
                    "Fsort" => isset($_POST['Fsort']) ? intval($_POST['Fsort']) : 1,
                    "Fstatus" => isset($_POST['Fstatus']) ? intval($_POST['Fstatus']) : 1,
                );
//                判断上传的图片是否存在并且不能为空
                if (isset($_FILES['Fimg']['name']) && !empty($_FILES['Fimg']['name'])) {
//                基本使用方法:
                    $file = new ExtendsYspUploadFile();
                    $file->max_size = 3 * 1024 * 1024; //       //限制文件大小 字节
                    $file->allow_type = "gif/jpg/bmp/png"; //允许上传的文件类型
                    $file->input_name = "Fimg";           //表单中的文本域名称
                    $file->save_path = PATH_UPLOAD . 'slide';      //保存路径
                    $file->rand_name = false;                   //随机文件名 (默认)
                    $file->reset_name = time() . '_' . $_SESSION['admin']['id'] . '_' . rand(0, 100);   //重命名
                    if ($file->save()) {
//                    echo "ok";               //保存文件，成功返回 true
                        $data['Fimg'] = str_replace(PATH_UPLOAD, '', $file->file_upload_path);
                    }
                }
                $rs = $this->M->addMenu(self::$advert_list, $data);
                if ($rs > 0) {
                    $href = str_replace('way=A', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }
        // 广告位列表
        if ($this->way == "S") {
            //分页参数设置
            //当前页码
            $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
            //每页条数
            $pagesize = 10;
            $page = ($page < 1) ? 1 : $page;
            //起始条数
            $start = ($page - 1) * $pagesize;
            //查询关键字
            $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : '';
            $where = $keywords ? "WHERE Fname LIKE '%$keywords%'" : '';

            //取总记录数
            $total = $this->M->getTotal(self::$advert_list, $where);
            $info_list = $this->M->getList(self::$advert_list, '*', $where, 'ORDER BY FcateId', "LIMIT $start,$pagesize");
            // 取菜单
            $menu_list = $this->M->getList(self::$advert_menu, 'Fid,Fname');
            $category_arr = array();
            foreach ($menu_list as $ls) {
                $category_arr[$ls['Fid']] = $ls['Fname'];
            }
            if ($total > 0) {
                $Pager = new ExtendsYspPager();
                $pagerlink = $Pager->getPager($total, $page, $pagesize);
            } else {
                $pagerlink = '对不起，没有相关信息';
            }
            include PATH_VIEWS . 'global/advert_manage/list.php';
        }
        // 广告位修改
        if ($this->way == "E") {
            if (!$_POST) {
                $menu_list = $this->M->getList(self::$advert_menu, 'Fid,Fname');
                $edit = $this->M->getView(self::$advert_list, 'Fid');
                include PATH_VIEWS . 'global/advert_manage/edit.php';
            } else {
                if ($_POST['FcateId'] == 0 || $_POST['FcateId'] == '') {
                    parent::getMsg('wrong', '请选择分类', URL);
                }
                $data = array(
                    "FcateId" => isset($_POST['FcateId']) ? intval($_POST['FcateId']) : 0,
                    "Fname" => isset($_POST['Fname']) ? trim($_POST['Fname']) : "",
                    "Fnum" => isset($_POST['Fnum']) ? trim($_POST['Fnum']) : "",
                    "Flink" => isset($_POST['Flink']) ? trim($_POST['Flink']) : "",
                    "FbgColor" => isset($_POST['FbgColor']) ? trim($_POST['FbgColor']) : "",
                    "Fwidth" => isset($_POST['Fwidth']) ? intval($_POST['Fwidth']) : 0,
                    "Fheight" => isset($_POST['Fheight']) ? intval($_POST['Fheight']) : 0,
                    "Fsort" => isset($_POST['Fsort']) ? intval($_POST['Fsort']) : 1,
                    "Fstatus" => isset($_POST['Fstatus']) ? intval($_POST['Fstatus']) : 1,
                );
//                判断上传的图片是否存在并且不能为空
                if (isset($_FILES['Fimg']['name']) && !empty($_FILES['Fimg']['name'])) {
//                基本使用方法:
                    $file = new ExtendsYspUploadFile();
                    $file->max_size = 2 * 1024 * 1024; //       //限制文件大小 字节
                    $file->allow_type = "gif/jpg/bmp/png"; //允许上传的文件类型
                    $file->input_name = "Fimg";           //表单中的文本域名称
                    $file->save_path = PATH_UPLOAD . 'slide';      //保存路径
                    $file->rand_name = false;                   //随机文件名 (默认)
                    $file->reset_name = time() . '_' . BaseYspCookie::getCookie($_COOKIE['admin']['id']) . '_' . rand(0, 100);   //重命名
                    if ($file->save()) {
//                    echo "ok";               //保存文件，成功返回 true
                        $data['Fimg'] = str_replace(PATH_UPLOAD, '', $file->file_upload_path);
                    }
                }
                $rs = $this->M->Edit(self::$advert_list, $data, 'Fid');
                if ($rs !==FALSE) {
                    $href = str_replace('way=E', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }
        // 广告位删除
        if ($this->way == "D") {
            $rs = $this->M->Del(self::$advert_list, 'Fid');
            if ($rs !== false) {
                $href = str_replace('&way=D', '&way=S', URL);
                parent::getMsg('right', '操作成功', $href);
                exit;
            } else {
                parent::getMsg('wrong', '对不起，操作失败', URL);
                exit;
            }
        }
    }

    /**
     * seo 优化管理
     */
    function seo() {
        // add
        if ($this->way == "A") {
            if (!$_POST) {
                include PATH_VIEWS . 'global/seo/add.php';
            } else {
                $data = array(
                    "Fname" => isset($_POST['Fname']) ? trim($_POST['Fname']) : '',
                    "Fclass" => isset($_POST['Fclass']) ? trim($_POST['Fclass']) : '',
                    "Ffunction" => isset($_POST['Ffunction']) ? trim($_POST['Ffunction']) : '',
                    "Ftitle" => isset($_POST['Ftitle']) ? trim($_POST['Ftitle']) : '',
                    "Fkeywords" => isset($_POST['Fkeywords']) ? trim($_POST['Fkeywords']) : '',
                    "Fdescription" => isset($_POST['Fdescription']) ? trim($_POST['Fdescription']) : '',
                    "Fsort" => isset($_POST['Fsort']) ? intval($_POST['Fsort']) : 1,
                );
                $rs = $this->M->addMenu(self::$seo, $data);
                if ($rs > 0) {
                    $href = str_replace('way=A', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }
        // list
        if ($this->way == "S") {

            //分页参数设置
            //当前页码
            $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
            //每页条数
            $pagesize = 10;
            $page = ($page < 1) ? 1 : $page;
            //起始条数
            $start = ($page - 1) * $pagesize;
            //查询关键字
            $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : '';
            $where = $keywords ? "WHERE Fname LIKE '%$keywords%'" : '';

            //取总记录数
            $total = $this->M->getTotal(self::$seo, $where);
            $info_list = $this->M->getList(self::$seo, '*', $where, 'ORDER BY Fsort', "LIMIT $start,$pagesize");
            if ($total > 0) {
                $Pager = new ExtendsYspPager();
                $pagerlink = $Pager->getPager($total, $page, $pagesize);
            } else {
                $pagerlink = '对不起，没有相关信息';
            }
            include PATH_VIEWS . 'global/seo/list.php';
        }
        // edit
        if ($this->way == "E") {
            if (!$_POST) {
                $edit = $this->M->getView(self::$seo, 'Fid');
                include PATH_VIEWS . 'global/seo/edit.php';
            } else {
                $data = array(
                    "Fname" => isset($_POST['Fname']) ? trim($_POST['Fname']) : '',
                    "Fclass" => isset($_POST['Fclass']) ? trim($_POST['Fclass']) : '',
                    "Ffunction" => isset($_POST['Ffunction']) ? trim($_POST['Ffunction']) : '',
                    "Ftitle" => isset($_POST['Ftitle']) ? trim($_POST['Ftitle']) : '',
                    "Fkeywords" => isset($_POST['Fkeywords']) ? trim($_POST['Fkeywords']) : '',
                    "Fdescription" => isset($_POST['Fdescription']) ? trim($_POST['Fdescription']) : '',
                    "Fsort" => isset($_POST['Fsort']) ? intval($_POST['Fsort']) : 1,
                );
                $rs = $this->M->Edit(self::$seo, $data, 'Fid');
                if ($rs !== false) {
                    $href = str_replace('way=E', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }
        // delete
        if ($this->way == "D") {
            $rs = $this->M->Del(self::$seo, 'Fid');
            if ($rs !== false) {
                $href = str_replace('&way=D', '&way=S', URL);
                parent::getMsg('right', '操作成功', $href);
                exit;
            } else {
                parent::getMsg('wrong', '对不起，操作失败', URL);
                exit;
            }
        }
    }

    /**
     * SMTP邮件发送设置
     */
    function smtpInfo() {

        if ($this->way == "A") {
            if (!$_POST) {
                include PATH_VIEWS . 'global/smtp/add.php';
            } else {
                $data = array(
                    "Fsmtp" => isset($_POST['Fsmtp']) ? trim($_POST['Fsmtp']) : '',
                    "Femail" => isset($_POST['Femail']) ? trim($_POST['Femail']) : '',
                    "Fpwd" => isset($_POST['Fpwd']) ? trim($_POST['Fpwd']) : '',
                    "FemailNick" => isset($_POST['FemailNick']) ? trim($_POST['FemailNick']) : '',
                    "FreplyEmail" => isset($_POST['FreplyEmail']) ? trim($_POST['FreplyEmail']) : '',
                    "FreplyNick" => isset($_POST['FreplyNick']) ? trim($_POST['FreplyNick']) : '',
                    "Fstatus" => isset($_POST['Fstatus']) ? intval($_POST['Fstatus']) : 1,
                    "Fsort" => isset($_POST['Fsort']) ? intval($_POST['Fsort']) : 1,
                );
                $rs = $this->M->addMenu(self::$smtp, $data);
                if ($rs > 0) {
                    $href = str_replace('way=A', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }
        if ($this->way == "S") {
            //分页参数设置
            //当前页码
            $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
            //每页条数
            $pagesize = 10;
            $page = ($page < 1) ? 1 : $page;
            //起始条数
            $start = ($page - 1) * $pagesize;
            //查询关键字
            $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : '';
            $where = $keywords ? "WHERE Fname LIKE '%$keywords%'" : '';

            //取总记录数
            $total = $this->M->getTotal(self::$smtp, $where);
            $info_list = $this->M->getList(self::$smtp, '*', $where, 'ORDER BY Fsort', "LIMIT $start,$pagesize");
            if ($total > 0) {
                $Pager = new ExtendsYspPager();
                $pagerlink = $Pager->getPager($total, $page, $pagesize);
            } else {
                $pagerlink = '对不起，没有相关信息';
            }
            include PATH_VIEWS . 'global/smtp/list.php';
        }
        if ($this->way == "E") {
            if (!$_POST) {
                $edit = $this->M->getView(self::$smtp, 'Fid');
                include PATH_VIEWS . 'global/smtp/edit.php';
            } else {
                $data = array(
                    "Fsmtp" => isset($_POST['Fsmtp']) ? trim($_POST['Fsmtp']) : '',
                    "Femail" => isset($_POST['Femail']) ? trim($_POST['Femail']) : '',
                    "Fpwd" => isset($_POST['Fpwd']) ? trim($_POST['Fpwd']) : '',
                    "FemailNick" => isset($_POST['FemailNick']) ? trim($_POST['FemailNick']) : '',
                    "FreplyEmail" => isset($_POST['FreplyEmail']) ? trim($_POST['FreplyEmail']) : '',
                    "FreplyNick" => isset($_POST['FreplyNick']) ? trim($_POST['FreplyNick']) : '',
                    "Fstatus" => isset($_POST['Fstatus']) ? intval($_POST['Fstatus']) : 1,
                    "Fsort" => isset($_POST['Fsort']) ? intval($_POST['Fsort']) : 1,
                );
                $rs = $this->M->Edit(self::$smtp, $data, 'Fid');
                if ($rs !== FALSE) {
                    $href = str_replace('way=E', 'way=S', URL);
                    parent::getMsg('right', '操作成功', $href, $time = 3);
                } else {
                    parent::getMsg('wrong', '操作失败', URL);
                }
            }
        }
        if ($this->way == "D") {
            $rs = $this->M->Del(self::$smtp, 'Fid');
            if ($rs !== false) {
                $href = str_replace('&way=D', '&way=S', URL);
                parent::getMsg('right', '操作成功', $href);
                exit;
            } else {
                parent::getMsg('wrong', '对不起，操作失败', URL);
                exit;
            }
        }
    }

}
